package com.dyw.Day08;

/**
 * Devil
 *
 * @author Devil
 * @create 2022-01-15-23:59
 *
 * 验证回文串
 * 方法一: 双指针
 */
public class Demo01 {
    public static void main(String[] args) {
        System.out.println(new Demo01().isPalindrome("0P"));
    }
    public boolean isPalindrome(String s) {
        char [] chars2 = new char[s.length()];
        int k=0;
        for (int i=0; i<s.length(); i++) {
            char c = s.charAt(i);
            if(Character.isAlphabetic(c)||Character.isDigit(c)){
                chars2[k++] = Character.toLowerCase(c);
            }
        }
        for (int i = 0; i < k/2; i++) {
            if(chars2[i]!=chars2[k-1-i]){
                return false;
            }
        }
        return true;
    }
}
